package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.biz.EmployeeVo;
import com.ruoyi.system.wx.login.domain.WxLoginVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Employee;
import com.ruoyi.system.service.IEmployeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工
 *
 * @author ruoyi
 * @date 2024 -11-29
 */
@RestController
@RequestMapping("/system/employee")
public class EmployeeController extends BaseController {
    @Autowired
    private IEmployeeService employeeService;

    /**
     * 查询【请填写功能名称】列表
     *
     * @param employee the employee
     * @return the table data info
     */
    @PreAuthorize("@ss.hasPermi('system:employee:list')")
    @GetMapping("/list")
    @ApiOperation("查询员工列表")
    public TableDataInfo list(Employee employee) {
        startPage();
        List<Employee> list = employeeService.selectEmployeeList(employee);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     *
     * @param response the response
     * @param employee the employee
     */
    @PreAuthorize("@ss.hasPermi('system:employee:export')")
    @Log(title = "【导出员工信息】", businessType = BusinessType.EXPORT)
    @ApiOperation("导出员工信息")
    @PostMapping("/export")
    public void export(HttpServletResponse response, Employee employee) {
        List<Employee> list = employeeService.selectEmployeeList(employee);
        ExcelUtil<Employee> util = new ExcelUtil<Employee>(Employee.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     *
     * @param id the id
     * @return the info
     */
    @PreAuthorize("@ss.hasPermi('system:employee:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据员工编号查询员工信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(employeeService.selectEmployeeById(id));
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param employee the employee
     * @return the ajax result
     */
    @PreAuthorize("@ss.hasPermi('system:employee:add')")
    @Log(title = "【添加员工】", businessType = BusinessType.INSERT)
    @ApiOperation("添加员工")
    @PostMapping
    public AjaxResult add(@RequestBody Employee employee) {
        return toAjax(employeeService.insertEmployee(employee));
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param employee the employee
     * @return the ajax result
     */
    @PreAuthorize("@ss.hasPermi('system:employee:edit')")
    @Log(title = "【编辑员工】", businessType = BusinessType.UPDATE)
    @ApiOperation("编辑员工")
    @PutMapping
    public AjaxResult edit(@RequestBody Employee employee) {
        return toAjax(employeeService.updateEmployee(employee));
    }

    /**
     * 删除【请填写功能名称】
     *
     * @param ids the ids
     * @return the ajax result
     */
    @PreAuthorize("@ss.hasPermi('system:employee:remove')")
    @Log(title = "【删除员工】", businessType = BusinessType.DELETE)
    @ApiOperation("删除员工")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(employeeService.deleteEmployeeByIds(ids));
    }





}
